'use strict';
const db = uniCloud.database()
const $ = db.command.aggregate
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {
		userId
	} = event;

	const user = await db.collection('user').doc(userId).get()
	const authorList = user.data[0].author_likes_ids;

	const list = await db.collection('user')
		.aggregate()
		.addFields({
			is_author: $.in(['$id', authorList])
		}).project({
			loginName: false,
			loginPwd: false,
			phone: false
		})
		.match({
			is_author: true
		}).end()
	//返回数据给客户端
	return {
		code: 0,
		msg: '获取关注用户成功',
		data: list.data
	}
};
